Xbasic

DBMAX Function

Syntax

Largest_Of_Values as N = DBMAX(C tablename,C tagname,A keyvalue,C field)

Arguments

tablename

The full drive, path, name, and extension of the table. If you omit the drive, path, and extension, Alpha Anywhere searches the directory of the current table.

tagname

The name of an index.

keyvalue

An explicit value or the name of a field in the table containing a value. Any type

field

An expression based on character, date, numeric, or exponent numeric field(s) in the Lookup_Table.

Description

Returns the maximum value of matching records in a specified table.

Discussion

DBMAX() searches the specified Lookup_Table for one or more records with the specified Key_Value, and returns the largest value of the values contained in Lookup_Expression. Note : If no records with matching key values are found, Alpha Anywhere returns a zero value.

Assume that a customer order table contains the following records:

CUSTOMER_ID

AMOUNT

C100

234.45

C100

123.67

C100

100.23

C101

231.34

C102

111.12

C102

987.23

The following expression returns the largest value in the Amount field for all the records in the Order table with a customer_ID number of "C100":

? dbmax("ORDER.DBF", "CUSTOMER_ID", "C100", "AMOUNT")
= "234.45"

This example uses the Customer_ID index to find the last (largest) date of an item sold to customer ID 00000004.

? dbmax("invoice_header", "Customer_ID", "00000004", "date")
= {01/18/2002}

See Also